home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / KoContextCelp.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-30  |  6.3 KB  |  280 lines

  1. /* This file is part of the KDE project
  2.    Copyright (C) 2002, Benoit Vautrin <benoit.vautrin@free.fr>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License as published by the Free Software Foundation; either
  7.    version 2 of the License, or (at your option) any later version.
  8.  
  9.    This library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Library General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Library General Public License
  15.    along with this library; see the file COPYING.LIB.  If not, write to
  16.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.  * Boston, MA 02110-1301, USA.
  18. */
  19.  
  20. #ifndef __KOCONTEXTHELPACTION_H__
  21. #define __KOCONTEXTHELPACTION_H__
  22.  
  23. #include <qwidget.h>
  24. #include <qbitmap.h>
  25. #include <qdockwindow.h>
  26.  
  27. #include <kaction.h>
  28. #include <koffice_export.h>
  29. class QPixmap;
  30. class QLabel;
  31. class QSimpleRichText;
  32.  
  33. class KoVerticalLabel : public QWidget
  34. {
  35.     Q_OBJECT
  36.     
  37.     public:
  38.         KoVerticalLabel( QWidget* parent = 0, const char* name = 0 );
  39.         ~KoVerticalLabel();
  40.         
  41.     public slots:
  42.         void setText( const QString& text );
  43.         
  44.     protected:
  45.         void paintEvent( QPaintEvent* );
  46.         
  47.     private:
  48.         QString m_text;
  49. }; // KoVerticalLabel
  50.  
  51. class KoHelpNavButton : public QWidget
  52. {
  53.     Q_OBJECT
  54.     
  55.     public:
  56.         enum NavDirection {
  57.             Up,
  58.             Down
  59.         };
  60.  
  61.         KoHelpNavButton( NavDirection d, QWidget* parent );
  62.  
  63.     signals:
  64.         void pressed();
  65.         void released();
  66.  
  67.     protected:
  68.         void paintEvent( QPaintEvent* );
  69.         void enterEvent( QEvent* );
  70.         void leaveEvent( QEvent* );
  71.  
  72.     private:
  73.         QBitmap      m_bitmap;
  74.         bool         m_pressed;
  75. }; // KoHelpNavButton
  76.  
  77. class KoTinyButton : public QWidget
  78. {
  79.     Q_OBJECT
  80.     
  81.     public:
  82.         enum Action {
  83.             Close,
  84.             Sticky
  85.         };
  86.  
  87.         KoTinyButton( Action a, QWidget* parent );
  88.  
  89.     signals:
  90.         void clicked();
  91.         void toggled( bool );
  92.  
  93.     protected:
  94.         void paintEvent( QPaintEvent* );
  95.         void mousePressEvent( QMouseEvent* );
  96.         void mouseReleaseEvent( QMouseEvent* );
  97.  
  98.     private:
  99.         QBitmap      m_bitmap;
  100.         bool         m_pressed;
  101.         Action       m_action;
  102.         bool         m_toggled;
  103. }; // KoTinyButton
  104.  
  105. class KoHelpView : public QWidget
  106. {
  107.     Q_OBJECT
  108.  
  109.     public:
  110.         KoHelpView( QWidget* parent );
  111.         ~KoHelpView();
  112.  
  113.         void setText( const QString& text );
  114.         bool eventFilter( QObject* watched, QEvent* e );
  115.  
  116.     signals:
  117.         void linkClicked( const QString& link );
  118.  
  119.     protected:
  120.         virtual void mousePressEvent( QMouseEvent* e );
  121.         virtual void mouseReleaseEvent( QMouseEvent* e );
  122.         virtual void mouseMoveEvent( QMouseEvent* e );
  123.         virtual void paintEvent( QPaintEvent* e );
  124.  
  125.     private:
  126.         QSimpleRichText* currentText;
  127.         QString currentAnchor;
  128. }; // KoHelpView
  129.  
  130. class KoHelpWidget : public QWidget
  131. {
  132.     Q_OBJECT
  133.  
  134.     public:
  135.         KoHelpWidget( QString help, QWidget* parent );
  136.  
  137.         void setText( QString text );
  138.         void timerEvent( QTimerEvent* );
  139.         void updateButtons();
  140.  
  141.     signals:
  142.         void linkClicked( const QString& link );
  143.  
  144.     public slots:
  145.         void scrollUp();
  146.         void scrollDown();
  147.         void startScrollingUp();
  148.         void startScrollingDown();
  149.         void stopScrolling();
  150.  
  151.     protected:
  152.         void resizeEvent( QResizeEvent* );
  153.  
  154.     private:
  155.         int              m_ypos;
  156.         bool             m_scrollDown;
  157.         QWidget*         m_helpViewport;
  158.         KoHelpView*      m_helpView;
  159.         KoHelpNavButton* m_upButton;
  160.         KoHelpNavButton* m_downButton;
  161. }; // KoHelpWidget
  162.  
  163. /**
  164.  * KoContextHelpPopup is the popup displayed by ContextHelpAction.
  165.  */
  166. class KoContextHelpPopup : public QWidget
  167. {
  168.     Q_OBJECT
  169.  
  170.     public:
  171.         KoContextHelpPopup( QWidget* parent = 0 );
  172.         ~KoContextHelpPopup();
  173.  
  174.     public slots:
  175.         void setContextHelp( const QString& title, const QString& text, const QPixmap* icon = 0 );
  176.         void setSticky( bool sticky ) { m_isSticky = sticky; }
  177.  
  178.     protected:
  179.         virtual void mousePressEvent( QMouseEvent* );
  180.         virtual void mouseMoveEvent( QMouseEvent* );
  181.         virtual void resizeEvent( QResizeEvent* );
  182.         virtual void paintEvent( QPaintEvent* );
  183.         virtual void windowActivationChange( bool );
  184.         virtual void keyPressEvent ( QKeyEvent* );
  185.         virtual void keyReleaseEvent ( QKeyEvent* );
  186.  
  187.     signals:
  188.         void wantsToBeClosed();
  189.         /**
  190.          * Connect to this signal to receive the href value of the links clicked.
  191.          */
  192.         void linkClicked( const QString& link );
  193.  
  194.     private:
  195.         KoHelpWidget*    m_helpViewer;
  196.         KoVerticalLabel* m_helpTitle;
  197.         QLabel*          m_helpIcon;
  198.         KoTinyButton*    m_close;
  199.         KoTinyButton*    m_sticky;
  200.  
  201.         QPoint           m_mousePos;
  202.         bool             m_isSticky;
  203. }; // KoContextHelpPopup
  204.  
  205. /**
  206.  * KoContextHelpAction provides a easy to use context help system.
  207.  *
  208.  * This action displays on demand a context help in a popup.
  209.  * The context help is set by the updateHelp slot.
  210.  */
  211. class KOFFICEUI_EXPORT KoContextHelpAction : public KToggleAction
  212. {
  213.     Q_OBJECT
  214.  
  215.     public:
  216.         KoContextHelpAction( KActionCollection* parentCollection, QWidget* parent = 0 );
  217.         virtual ~KoContextHelpAction();
  218.  
  219.     public slots:
  220.         void updateHelp( const QString& title, const QString& text, const QPixmap* icon = 0 );
  221.         void closePopup();
  222.  
  223.     signals:
  224.         /**
  225.          * Connect to this signal to receive the href value of the links clicked.
  226.          */
  227.         void linkClicked( const QString& link );
  228.  
  229.     private:
  230.         KoContextHelpPopup* m_popup;
  231. }; // KoContextHelpAction
  232.  
  233. class KoContextHelpWidget : public QWidget
  234. {
  235.     Q_OBJECT
  236.  
  237.     public:
  238.         KoContextHelpWidget( QWidget* parent = 0, const char* name = 0 );
  239.         ~KoContextHelpWidget();
  240.  
  241.     public slots:
  242.         void setContextHelp( const QString& title, const QString& text, const QPixmap* icon = 0 );
  243.  
  244.     signals:
  245.         /**
  246.          * Connect to this signal to receive the href value of the links clicked.
  247.          */
  248.         void linkClicked( const QString& link );
  249.  
  250.     private:
  251.         KoHelpWidget*    m_helpViewer;
  252.         KoVerticalLabel* m_helpTitle;
  253.         QLabel*          m_helpIcon;
  254. }; // KoContextHelpWidget
  255.  
  256. class KoContextHelpDocker : public QDockWindow
  257. {
  258.     Q_OBJECT
  259.  
  260.     public:
  261.         KoContextHelpDocker( QWidget* parent = 0, const char* name = 0 );
  262.         ~KoContextHelpDocker();
  263.  
  264.     public slots:
  265.         void setContextHelp( const QString& title, const QString& text, const QPixmap* icon = 0 );
  266.  
  267.     signals:
  268.         /**
  269.          * Connect to this signal to receive the href value of the links clicked.
  270.          */
  271.         void linkClicked( const QString& link );
  272.  
  273.     private:
  274.         KoHelpWidget*    m_helpViewer;
  275.         KoVerticalLabel* m_helpTitle;
  276.         QLabel*          m_helpIcon;
  277. }; // KoContextHelpDocker
  278.  
  279. #endif /* __KOCONTEXTHELPACTION_H__ */
  280.